package com.infore.siteManagement.controller.equipment;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.alibaba.fastjson.JSONObject;
import com.infore.siteManagement.dto.EquipmentSampleAddDto;
import com.infore.siteManagement.select.dto.QueryParamDto;
import com.infore.siteManagement.select.util.PageObject;
import com.infore.siteManagement.service.equipment.IEquipSampleService;
import com.infore.siteManagement.util.ResultEntity;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "仪器实例管理接口", tags = { "仪器实例管理接口" })
@RestController
@RequestMapping("/equipSample")
public class EquipSampleController {

	@Autowired
	private IEquipSampleService iEquipSampleService;

	@ApiOperation(value = "查询仪器模板通用接口")
	@ResponseBody
	@PostMapping(value = "/query")
	public ResultEntity query(@RequestBody(required = false) QueryParamDto queryParamDto) {
		return iEquipSampleService.query(queryParamDto);
	}

	@ApiOperation(value = "删除仪器模板通用接口")
	@ApiImplicitParams(@ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true, dataType = "String"))
	@DeleteMapping(value = "/delete")
	public ResultEntity delete(String id) {
		return iEquipSampleService.delete(id);
	}

	@ApiOperation(value = "编辑/新增仪器模板通用接口")
	@ResponseBody
	@PostMapping(value = "/edit")
	public ResultEntity edit(String jsons, MultipartFile[] imageFiles){
		EquipmentSampleAddDto equipmentSampleAddDto = JSONObject.parseObject(jsons, EquipmentSampleAddDto.class);
		return iEquipSampleService.edit(equipmentSampleAddDto, imageFiles);
	}

	@ApiOperation(value = "查询监测站下仪器信息接口")
	@GetMapping(value = "/queryByStation")
	public ResultEntity querySingleByStation(String stationId,String mn, PageObject pageObject) {
		return iEquipSampleService.querySingleByStation(stationId,mn, pageObject);
	}
}